//------------------------------------------------------------------------------
//  <copyright file="KukaLBR4Tracing.h" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  </copyright>
//------------------------------------------------------------------------------

#pragma once

#include "stdafx.h"

namespace KukaLBR4ControllerCommonNS
{
	class KukaLBR4Tracing
	{
	public:

		enum TimingEventTypes
		{
			RecvCmdFromPipeline,
			RecvFriStatus,
			SendFriCmd,
			FriStatusToCmdDelta,
			DoNothingType,
			CsmdStopped
		};

		/// <summary>
		/// Register ETW providers for KUKALBR4Controller
		/// </summary>
		static void RegisterProviders();

		/// <summary>
		/// Unregister ETW providers for KUKALBR4Controller
		/// </summary>
		static void UnregisterProviders();

		/// <summary>
		/// Write an ETW controller timing event.
		/// This creates an ETW log entry with an integer that indicates the type of event, along with the
		/// time at which the event occurced, and the time since the last event of this type occured.
		/// </summary>
		/// <param name="currentTime"> Time the event occured </param>
		/// <param name="lastTime"> Time of the previous occurence of the same event </param>
		/// <param name="eventDescriptor"> The event descriptor </param>
		/// <param name="eventType"> Integer indicating event type </param>
		static void WriteTimingEvent(__int64 currentTime, __int64 lastTime, EVENT_DESCRIPTOR eventDescriptor, int eventType);

		/// <summary> Write an event to the KukaLBR4ControllerProvider </summary>
		/// <param name="e"> Pointer to event descriptor </param>
		/// <param name="userDataCount"> Length of user data </param>
		/// <param name="userData"> User data </param>
		static void WriteKukaLBR4ControllerEvent(PCEVENT_DESCRIPTOR e, ULONG userDataCount, PEVENT_DATA_DESCRIPTOR userData);

		/// <summary>
		/// Returns true if ETW timing events are enabled.
		/// </summary>
		/// <param name="e"> Pointer to event descriptor. </param>
		/// <returns> True if event is enabled. </returns>
		static bool IsTimingEventsEnabled(PCEVENT_DESCRIPTOR e);

		/// <summary> 
		/// Indicates whether or not an event in the KukaLBR4ControllerProvider is enabled 
		/// </summary>
		/// <param name="e"> Pointer to event descriptor. </param>
		/// <returns> True if event is enabled. </returns>
		static bool IsControllerEventEnabled(PCEVENT_DESCRIPTOR e);
	};
}
